package com.anysoft.utils;

import android.content.Context;
import android.util.Log;

import com.anysoft.StaticField;
import com.umeng.analytics.MobclickAgent;

import java.util.HashMap;

/**
 * Created by lty on 2017/10/20.
 * 友盟事件统计工具类（计数事件)
 */

public class AnalyticsEventUtils {
    private static final String DEVICEID = "deviceid";
    private static final String DEVICEVERSIOIN = "device_version";
    private static final String IMSI = "imsi";
    private static final String CHANNEL = "appChannel";
    private static final String PHONEMODEL = "phone_model";
    private static final String TAG = "MobclickAgent";

    /**
     * 普通登录成功
     *
     * @param context
     */
    public static void toLoginNormalEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_login_normal", map);
        Log.e(TAG, "普通登录成功 ");
    }

    /**
     * 指纹登录成功
     *
     * @param context
     */
    public static void toLoginFingerEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_login_finger", map);
        Log.e(TAG, "指纹登录成功 ");
    }

    /**
     * 手势登录成功
     *
     * @param context
     */
    public static void toLoginGesturesEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_login_gestures", map);
        Log.e(TAG, "手势登录成功 ");
    }

    /**
     * 头像登录成功
     *
     * @param context
     */
    public static void toLoginAvatarEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        int duration = getCurrentTime();
        MobclickAgent.onEventValue(context, "a_login_avatar", map, duration);
        Log.e(TAG, "头像登录成功 ");
    }

    /**
     * 退出登录
     *
     * @param context
     */
    public static void toLogoutEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        int duration = getCurrentTime();
        MobclickAgent.onEventValue(context, "a_logout", map, duration);
        Log.e(TAG, "退出登录 ");
    }


    /**
     * 设置密码
     *
     * @param context
     */
    public static void toSetPasswordEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_setPassword", map);
        Log.e(TAG, "设置密码 ");
    }


    /**
     * 开户成功
     *
     * @param context
     */
    public static void toOpenAccountEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_open_account", map);
        Log.e(TAG, "开户成功 ");
    }

    /**
     * 填写真实姓名(开户第一步的1)
     *
     * @param context
     */
    public static void toFillRealNameEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_realName", map);
        Log.e(TAG, "填写真实姓名(开户第一步的1) ");
    }

    /**
     * 填写银行账户(开户第一步的2)
     *
     * @param context
     */
    public static void toFillBankAccountEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_bankAcco", map);
        Log.e(TAG, "开户填写银行账户(开户第一步的2)成功 ");
    }

    /**
     * 填写信息(开户第二步)
     *
     * @param context
     */
    public static void toFillInfoEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_fillInfo", map);
        Log.e(TAG, "填写信息(开户第二步) ");
    }

    /**
     * 点击总资产事件
     *
     * @param context
     */
    public static void toClickTotalAssetEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_asset_totalAsset", map);
        Log.e(TAG, "点击总资产事件");
    }

    /**
     * 点击理财日历
     *
     * @param context
     */
    public static void toClickCalendarEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_asset_calendar", map);
        Log.e(TAG, "点击理财日历");
    }

    /**
     * 购买结果事件
     *
     * @param context
     */
    public static void toBuyResultEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_buy_result", map);
        Log.e(TAG, "购买结果事件");
    }

    /**
     * 取现确认事件
     *
     * @param context
     */
    public static void toRedeemConfirmEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_redeem_confirm", map);
        Log.e(TAG, "取现确认事件");
    }


    /**
     * 取现结果
     *
     * @param context
     */
    public static void toRedeemResultEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_redeem_result", map);
        Log.e(TAG, "取现结果");
    }


    /**
     * 取现到银行卡事件
     *
     * @param context
     */
    public static void toRedeemApplyBankEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_redeem_apply_bank", map);
        Log.e(TAG, "取现到银行卡事件");
    }

    /**
     * 银行卡购买申请事件
     *
     * @param context
     */
    public static void toBuyApplyBankEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_buy_apply_bank", map);
        Log.e(TAG, "银行卡购买申请事件");
    }


    /**
     * 购买确认事件
     *
     * @param context
     */
    public static void toBuyConfirmEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_buy_confirm", map);
        Log.e(TAG, " 购买确认事件");
    }

    /**
     * 现金快线购买申请
     *
     * @param context
     */
    public static void toBuyApply_XJKXEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_buy_apply_482002", map);
        Log.e(TAG, "现金快线购买申请");
    }

    /**
     * 取现到现金快线
     *
     * @param context
     */
    public static void toRedeemApplay_XJKXEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_redeem_apply_482002", map);
        Log.e(TAG, "取现到现金快线");
    }

    /**
     * 转换申请
     *
     * @param context
     */
    public static void toTransferApplayEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_transfer_apply", map);
        Log.e(TAG, "转换申请");
    }

    /**
     * 转换确认
     *
     * @param context
     */
    public static void toTransferConfirmEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_transfer_confirm", map);
        Log.e(TAG, "转换确认");
    }

    /**
     * 转换结果
     *
     * @param context
     */
    public static void toTransferResultEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "t_transfer_result", map);
        Log.e(TAG, "转换结果");
    }

    /**
     * 点击全部组合
     *
     * @param context
     */
    public static void toClickAllGroupEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "zt_q_allGroup", map);
        Log.e(TAG, "点击全部组合");
    }

    /**
     * 点击组合进入组合详情
     *
     * @param context
     */
    public static void toGroupDetailEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "zt_q_group_details", map);
        Log.e(TAG, "点击组合进入组合详情");
    }

    /**
     * 购买组合
     *
     * @param context
     */
    public static void toBuyBeginEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "zt_t_buy_begin", map);
        Log.e(TAG, "购买组合");
    }

    /**
     * 出现风险提示时
     *
     * @param context
     */
    public static void toRiskHintEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "zt_t_buy_riskHint", map);
        Log.e(TAG, "出现风险提示时");
    }

    /**
     * 出现投资意愿声明
     *
     * @param context
     */
    public static void toBuyStatemnetEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "zt_t_buy_statement", map);
        Log.e(TAG, "出现投资意愿声明");
    }

    /**
     * 购买详情确定按钮
     *
     * @param context
     */
    public static void toBuyDetailConfirmEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "zt_t_buy_success", map);
        Log.e(TAG, "购买详情确定按钮");
    }


    /**
     * 公告分享
     *
     * @param context
     */
    public static void toShareNoticeEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_share_notice", map);
        Log.e(TAG, "公告分享");
    }

    /**
     * 新闻资讯分享
     *
     * @param context
     */
    public static void toShareNewsEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_share_news", map);
        Log.e(TAG, "新闻资讯分享");
    }

    /**
     * 基金分享
     *
     * @param context
     */
    public static void toShareFundEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_share_fund", map);
        Log.e(TAG, "基金分享");
    }

    /**
     * 广告分享
     *
     * @param context
     */
    public static void toShareBannerEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_share_banner", map);
        Log.e(TAG, "广告分享");
    }

    /**
     * 注册流程
     *
     * @param context
     */
    public static void toShareRegisterProcessEvent(Context context) {
        HashMap<String, String> map = getInstallMap(context);
        MobclickAgent.onEvent(context, "a_share_regist_process", map);
        Log.e(TAG, "注册流程");
    }


    /*-------------------------------------------------------------------------------*/
    private static HashMap<String, String> getInstallMap(Context context) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(PHONEMODEL, DeviceUtils.getSystemModel());
        map.put(DEVICEID, DeviceUtils.getDeviceManufacturer());
        map.put(DEVICEVERSIOIN, DeviceUtils.getSystemVersion());
        map.put(CHANNEL, StaticField.getChannel(context));
        return map;
    }

    private static int getCurrentTime() {
        return new Long(System.currentTimeMillis()).intValue();
    }
}
